package com.it;

public class ArrayDemo {
    public static void main(String[] args) {
        //动态数组
        int[] arr1 = new int[3];//常用
        String[] str = new String[5];//常用

        //静态数组
        int[] arr2 = {1, 2, 3};//常用
        int[] arr3 = new int[]{1, 2, 3};//不常用
        int[] arr4 = new int[]{2, 3, 4};//不常用


        //获取数组长度，Get array length
        int len = arr4.length;
        System.out.println("len = " + len);

        //给数组赋值，Assign values to arrays
        arr1[0] = 100;
        arr1[1] = 200;
        arr1[2] = 300;


        //数组遍历
        for (int i = 0; i < arr4.length; i++) {
            System.out.println(arr4[i]);
        }


        //给数组赋值0-99的随机数
        int[] arrs = new int[10];
        for (int i = 0; i < arrs.length; i++) {
            int random = (int) (Math.random() * 100);//确认随机数为0-99范围
            arrs[i] = random;
            System.out.println(arrs[i]);
        }



    }
}
